package com.base.caselib.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.TextView;

import com.base.caselib.R;
import com.base.caselib.bean.LawStatuteBean;
import com.base.commonlib.recy.BasicRecyViewHolder;
import com.base.commonlib.recy.HFSingleTypeRecyAdapter;

/**
 * Created by Administrator on 2019/10/21.
 */

public class LawStatuteListAdapter extends HFSingleTypeRecyAdapter<LawStatuteBean,LawStatuteListAdapter.ViewHolder> {

    Context mContext;
    private int selectedItem;

    public LawStatuteListAdapter(int resId, Context mContext) {
        super(resId);
        this.mContext=mContext;
        selectedItem = 0;
    }

    @Override
    public ViewHolder buildViewHolder(View itemView) {
        return new ViewHolder(itemView);
    }
    public void selectTaskListItem(int pos) {

        int previousItem = selectedItem;
        selectedItem = pos;

        notifyItemChanged(previousItem);
        notifyItemChanged(pos);

    }

    @Override
    public void bindDataToHolder(ViewHolder holder, LawStatuteBean bean, int position) {
        if (selectedItem == position) {
            holder.tv_dictvalue.setText(bean.getDictValue());
            holder.tv_dictvalue.setTextColor(Color.parseColor("#50B400"));
        }else {
            holder.tv_dictvalue.setText(bean.getDictValue());
            holder.tv_dictvalue.setTextColor(Color.parseColor("#636363"));
        }
        holder.tv_dictvalue.setText(bean.getDictValue());
    }

    public static class ViewHolder extends BasicRecyViewHolder {

        TextView tv_dictvalue;

        public ViewHolder(View itemView) {
            super(itemView);
            tv_dictvalue=(TextView) itemView.findViewById(R.id.tv_dictvalue);
        }


    }
}
